package code_test
import java.util.ArrayList

import weka.core.{Attribute, FastVector, Instance, Instances}

import scala.collection.JavaConversions._

object RevokeJavaCollections{
  def getList={
    val list=new ArrayList[String]()
    list.add("fabcd")
    list.add("abcde")
    list
  }
  def main(args: Array[String]) {
    val list=getList
    list.foreach(println)
    val length: Attribute = new Attribute("length")
    val weight: Attribute = new Attribute("weight")
    //println(weight)

    // Create vector to hold nominal values "first", "second", "third"
    val my_nominal_values: FastVector = new FastVector(3)
    my_nominal_values.addElement("first")
    my_nominal_values.addElement("second")
    my_nominal_values.addElement("third")

    // Create nominal attribute "position"
    val position: Attribute = new Attribute("position", my_nominal_values)

    // Create vector of the above attributes
    val attributes: FastVector = new FastVector(3)
    attributes.addElement(length)
    attributes.addElement(weight)
    attributes.addElement(position)
    println(position.index())
    println(position.name())
    /*
    attributes.addElement(new Attribute("length"))
    attributes.addElement(new Attribute("weight"))
    attributes.addElement(new Attribute("position"))
    */
    // Create the empty dataset "race" with above attributes
    val race: Instances = new Instances("race", attributes, 0)
    println(position.index())
    println(new Attribute("position",my_nominal_values).index())
    // Make position the class attribute
    race.setClassIndex(position.index)
    val inst: Instance = new Instance(3)

    // Set instance's values for the attributes "length", "weight", and "position"
    //inst.setValue(length, 5.3)
    inst.setValue(weight, 300)
    inst.setValue(position, "first")

    // Set instance's dataset to be the dataset "race"
    inst.setDataset(race)
    println(race)
  }

}
